home *** CD-ROM | disk | FTP | other *** search
/ BBS in a Box 7 / BBS in a Box - Macintosh - Volume VII (BBS in a Box) (January 1993).iso / Files / Prog / T / TC Prog Guide.cpt / picture ƒ / anring.c < prev    next >
Text File  |  1990-11-09  |  2KB  |  72 lines

  1. /*
  2. *    FILE:        anring.c
  3. *    AUTHOR:        R. Gonzalez
  4. *    CREATED:    November 8, 1990
  5. *
  6. *    defines methods for ring animated segment
  7. */
  8.  
  9. # include    "anring.h"
  10. # include    "trans.h"
  11. # include    "atring.h"
  12.  
  13. # define    NUM_SATELLITES        2
  14. # define    RADIUS                3.
  15. # define    SATELLITE_TYPE        Atomic_Ring
  16. # define    ANIMATED_SATELLITES    TRUE
  17. # define    ANGULAR_VELOCITY    PI/20.
  18.  
  19. /******************************************************************
  20. *    initialize
  21. ******************************************************************/
  22. boolean    Animated_Ring::init(void)
  23. {
  24.     int                i;
  25.     Translation        *transl;
  26.     Rotation_Y        *roty;
  27.     Transformation    *combination;
  28. /*    The following temps are needed due to a bug in Think C when
  29.     handling arrays of pointers, when the array is an instance var.
  30. */
  31.     Segment            *temp_seg;
  32.     Transformation    *temp_trans;
  33.     
  34.     Animated_Segment::init();
  35.     
  36.     transl = new(Translation);
  37.     transl->init();
  38.     transl->set(0.,0.,RADIUS);
  39.     roty = new(Rotation_Y);
  40.     roty->init();
  41.     combination = new(Transformation);
  42.     combination->init();
  43.     
  44.     num_segments = NUM_SATELLITES;
  45.     
  46.     for (i=0 ; i<NUM_SATELLITES ; i++)
  47.     {
  48.         temp_seg = new(SATELLITE_TYPE);
  49.         segment[i] = temp_seg;
  50.         segment[i]->init();
  51.         roty->set(i*2.*PI/NUM_SATELLITES);
  52.         combination->combine(transl,roty);
  53.         segment[i]->move(combination);
  54.         temp_trans = new(Rotation_Y);
  55.         animation[i] = temp_trans;
  56.         animation[i]->init();
  57.         ((Rotation_Y*) animation[i])->set(ANGULAR_VELOCITY);
  58.         if (ANIMATED_SATELLITES)
  59.             log_animated_segment(segment[i]);
  60.     }
  61.     
  62.     transl->destroy();
  63.     delete(transl);
  64.     roty->destroy();
  65.     delete(roty);
  66.     combination->destroy();
  67.     delete(combination);
  68.     
  69.     return TRUE;
  70. }
  71.  
  72.